/**
 * 微信消息页面js
 * 版权所有：上海戈品投资管理有限公司
 *   author king
     功能说明：微信消息列表
     创建日期：2015-10-15
     修改记录：
     备注说明：
 */

$(document).ready(function() {
	wxMsgContentList();
});


/**
 * 消息列表
 * @returns
 */
var wxMsgContentList = function(){
	
	var senderNickName=$("#senderNickName").val();
	var sendType=$("#sendTypeList").val();
	var sendStatus=$("#sendStatusList").val();
	var checkTime=$("#checkTime").val();
	var TimeType=$("#TimeSelectList").val();
	
	
	var datas =  {"p":"wxMsgManage","m":"query","senderNickName":senderNickName,"sendType":sendType,"sendStatus":sendStatus,"checkTime":checkTime,"TimeType":TimeType};
	var columnDefine = {"id":"序号","senderName":"发信息操作人","createTime":"发送信息开始时间","endTime":"发送信息结束时间","sendType":"发送类型","status":"发送状态","content":"内容","senderUid":"发送人ID"};
	
	var formatters={
	            "createTime": function (column, rowData)
	            {
    				var newTime= new Date(rowData.createTime);
    				var rowText=newTime.getFullYear()+'-'+getTheSureTime((newTime.getMonth()+1))+'-'
    				+getTheSureTime(newTime.getDate())+' '+getTheSureTime(newTime.getHours())+':'
    				+getTheSureTime(newTime.getMinutes())+':'+getTheSureTime(newTime.getSeconds());
    				return rowText;
	            },
	            "endTime": function (column, rowData)
	            {
	            	var newTime= new Date(rowData.endTime);
	            	var rowText=newTime.getFullYear()+'-'+getTheSureTime((newTime.getMonth()+1))+'-'
	            	+getTheSureTime(newTime.getDate())+' '+getTheSureTime(newTime.getHours())+':'
	            	+getTheSureTime(newTime.getMinutes())+':'+getTheSureTime(newTime.getSeconds());
	            	return rowText;
	            },
	            "sendType": function (column, rowData)
	            {
	            	var str="";
    				switch (rowData.sendType) {
					case 0:
						str="多选发微信";
						break;
					case 1:
						str="给所有快递员发送消息";
						break;
					case 4:
						str="给通过审核快递员发送消息";
						break;
					case 5:
						str="给未通过审核快递员发送消息";
						break;
					case 6:
						str="给未审核快递员发送消息";
						break;
					case 2:
						str="只给用户发送消息";
						break;
					case 3:
						str="群发消息";
						break;
					default:
						break;
					}
    				return str;
	            },
	            "status": function (column, rowData)
	            {
       				var str="";
    				switch (rowData.status) {
					case 0:
						str="发送中...";
						break;
					case 1:
						str="发送成功";
						break;
					case 2:
						str="发送失败";
						break;
					default:
						break;
					}
    				return str;
	            }
	 };
	 var buttons =''; //操作按钮
		buttons+='<p>';
		buttons+='<button type=\'button\' class=\'btn btn-w-m btn-info\' onclick="showMsgDetail();">查看详情</button>';
		buttons+='</p>';
	   hui.pager('service',datas ,"dataList", columnDefine , formatters , buttons ); //分页查询
	
};

function getTheSureTime(emp){
	return emp>9?emp:"0"+emp;
}

/**
 * 查看详情
 * @returns
 */
var showMsgDetail = function(){
	var data = $('#pop_win .data').text();
	var json = eval('('+data+')');
	window.location.href='page?p=page/wxMessage&wxMsgId=' + json.id ;
};


